package com.lovegu.collection.map;

import org.junit.Test;

import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;

/**
 * @author 老顾
 * @title: LinkedHashMapTest
 * @projectName java-restudy
 * @email: 1437594522@qq.com
 * @date 2022/9/24 11:16
 */
public class LinkedHashMapTest {
    Map<String,String> map = new LinkedHashMap<>(16);
    @Test
    public void testFor(){
        map.put("m","abc");
        map.put("a","abc");
        map.put("g","bcd");
        map.put("s","cde");
        map.put("z","def");
        Iterator<Map.Entry<String, String>> iterator = map.entrySet().iterator();
        while (iterator.hasNext()){
            Map.Entry<String, String> next =
                    iterator.next();
            System.out.println(next.getKey());
            System.out.println(next.getValue());
        }
    }
}
